import { ItemPanelController } from "./ItemPanelController";
import { labelpanelcontroller, labelpanelcontroller2 } from "./labelpanelcontroller";
import ScrollViewManager from "./ScrollViewManager";

const { ccclass, property } = cc._decorator;

@ccclass
export default class ScrollViewtest extends cc.Component {

    @property(cc.Node)
    SctrollView_Normal: cc.Node = null;
    @property(cc.Node)
    SctrollView_L: cc.Node = null;

    @property()
    UseScroll_L = true

    _SctrollView
    _SctrollViewMgr

    panels = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21];

    onLoad() {
        this._SctrollView = this.UseScroll_L == true ? this.SctrollView_L : this.SctrollView_Normal;
        this._SctrollViewMgr = this.UseScroll_L == true ? labelpanelcontroller : labelpanelcontroller2;
        this.SctrollView_Normal.active = this.UseScroll_L == false;
        this.SctrollView_L.active = this.UseScroll_L == true;
    }

    start() {
        let crollter = this._SctrollView.getComponent(ScrollViewManager);
        crollter.SetScroll(this.panels, this._SctrollViewMgr);
        crollter.OnStartPanel();
    }

    TurnTop() {
        let crollter = this._SctrollView.getComponent(ScrollViewManager);
        crollter.TurnToTop();
    }

    TurnDown() {
        this.panels = [1, 2, 3, 4, 5, 6]
        let crollter = this._SctrollView.getComponent(ScrollViewManager);
        crollter.ChangeItemList(this.panels);
    }

    Turn() {
        this.panels = [1, 2, 3]
        let crollter = this._SctrollView.getComponent(ScrollViewManager);
        crollter.ChangeItemList(this.panels);
    }

}